 package server.maps;

 import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
 import provider.MapleData;
 import provider.MapleDataProvider;
 import provider.MapleDataProviderFactory;
 import provider.MapleDataTool;
 import tools.Pair;
 import tools.StringUtil;


 public class MapleReactorFactory
 {
/*  16 */   private static final MapleDataProvider data = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Reactor.wz"));
/*  17 */   private static final Map<Integer, MapleReactorStats> reactorStats = new HashMap<>();

   public static MapleReactorStats getReactor(int rid) {
/*  20 */     MapleReactorStats stats = reactorStats.get(Integer.valueOf(rid));
/*  21 */     if (stats == null) {
/*  22 */       int infoId = rid;
/*  23 */       MapleData reactorData = data.getData(StringUtil.getLeftPaddedStr(Integer.toString(infoId) + ".img", '0', 11));
/*  24 */       MapleData link = reactorData.getChildByPath("info/link");
/*  25 */       if (link != null) {
/*  26 */         infoId = MapleDataTool.getIntConvert("info/link", reactorData);
/*  27 */         stats = reactorStats.get(Integer.valueOf(infoId));
       }
/*  29 */       if (stats == null) {
/*  30 */         stats = new MapleReactorStats();
/*  31 */         reactorData = data.getData(StringUtil.getLeftPaddedStr(Integer.toString(infoId) + ".img", '0', 11));
/*  32 */         if (reactorData == null) {
/*  33 */           return stats;
         }










/*  45 */         boolean canTouch = (MapleDataTool.getInt("info/activateByTouch", reactorData, 0) > 0);
/*  46 */         boolean areaSet = false;
/*  47 */         boolean foundState = false; byte i;
/*  48 */         for (i = 0;; i = (byte)(i + 1)) {
/*  49 */           MapleData reactorD = reactorData.getChildByPath(String.valueOf(i));
/*  50 */           if (reactorD == null) {
             break;
           }
/*  53 */           MapleData reactorInfoData_ = reactorD.getChildByPath("event");
/*  54 */           if (reactorInfoData_ != null && reactorInfoData_.getChildByPath("0") != null) {
/*  55 */             MapleData reactorInfoData = reactorInfoData_.getChildByPath("0");
/*  56 */             Pair<Integer, Integer> reactItem = null;
/*  57 */             boolean find = false;
/*  58 */             for (MapleData mapleData : reactorInfoData.getChildren()) {
/*  59 */               if (mapleData.getName().equals("type")) {
/*  60 */                 find = true;
               }
             }













/*  76 */             if (find) {
/*  77 */               int type = MapleDataTool.getIntConvert("type", reactorInfoData);
/*  78 */               if (type == 100) {
/*  79 */                 int reactItemid = MapleDataTool.getIntConvert("0", reactorInfoData, -1);
/*  80 */                 int reactItemNum = MapleDataTool.getIntConvert("1", reactorInfoData, 1);

/*  82 */                 if (reactItemid != -1) {
/*  83 */                   reactItem = new Pair(Integer.valueOf(reactItemid), Integer.valueOf(reactItemNum));
                 }

/*  86 */                 if (!areaSet) {
/*  87 */                   stats.setTL(MapleDataTool.getPoint("lt", reactorInfoData));
/*  88 */                   stats.setBR(MapleDataTool.getPoint("rb", reactorInfoData));
/*  89 */                   areaSet = true;
                 }
               }
/*  92 */               foundState = true;
/*  93 */               stats.addState(i, type, reactItem, (byte)MapleDataTool.getIntConvert("state", reactorInfoData), MapleDataTool.getIntConvert("timeOut", reactorInfoData_, -1), (byte)(canTouch ? 2 : ((MapleDataTool.getIntConvert("2", reactorInfoData, 0) > 0 || reactorInfoData.getChildByPath("clickArea") != null || type == 9) ? 1 : 0)));
             }
           } else {
/*  96 */             stats.addState(i, 999, null, (byte)(foundState ? -1 : (i + 1)), 0, (byte)0);
           }
         }
/*  99 */         reactorStats.put(Integer.valueOf(infoId), stats);
/* 100 */         if (rid != infoId) {
/* 101 */           reactorStats.put(Integer.valueOf(rid), stats);
         }
       } else {
/* 104 */         reactorStats.put(Integer.valueOf(rid), stats);
       }
     }
/* 107 */     return stats;
   }
 }


/* Location:              C:\PGX\Server.jar!\server\maps\MapleReactorFactory.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */